<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="../../lib/layui-v2.6.3/css/layui.css" media="all" rel="stylesheet">
    <link href="../../css/public.css" media="all" rel="stylesheet">
    <link href="../../css/diy/form1.css" rel="stylesheet">
    <script src="../../lib/layui-v2.6.3/layui.js"></script>
    <script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script src="../../js/template-web.js"></script>
    <script src="../../js/lay-module/layuimini/miniTab.js"></script>
    <script src="../../frontstatic/js/notify.js"></script>
    <script src="../../frontstatic/js/notify_stand.js"></script>
    <title>退货管理</title>
</head>
<body>
<div id="commditytable">
    <div style="background-color: #FFFFFF;height: 200px;border-radius: 15px">
        <div style="padding-left: 40px;padding-top:15px">
            <img height="25" loading="lazy" src="../../images/shouzuo.png" width="25">
            <span>按条件进行检索</span>
        </div>
        <hr>
        <form class="layui-form" style="padding-top: 30px" lay-filter="exampleOrder">
            <div class="layui-inline">
                <label class="layui-form-label">订单编号：</label>
                <div class="layui-input-inline">
                    <input autocomplete="off" class="layui-input" id="orderUuid" name="orderUuid" placeholder="请输入" type="text">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">售后单号：</label>
                <div class="layui-input-inline">
                    <input autocomplete="off" class="layui-input" id="saleUuid" name="saleUuid" placeholder="请输入" type="text">
                </div>
            </div>
            <div class="layui-form-item" id="selectBtn">
                <div class="layui-input-block">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="layui-btn layui-btn-normal" id="orderButton" type="button">查询
                </button>
                    <button class="layui-btn layui-btn-primary  layui-btn-sm" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
    <div style="margin-left: -90px">
        <div style="width: 1650px">
            <table class="layui-table table-date" id="orderReturnTable" lay-filter="orderTable"></table>
        </div>
    </div>
</div>
</body>
<script id="barlist" type="text/html">
    {{# if(d.statics == 1){ }}
    <a class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs " lay-event="agree">同意</a>
    <a class="layui-btn layui-btn-primary layui-border-orange layui-btn-xs" lay-event="reject">驳回</a>
    {{#  } }}
    {{# if(d.cargoStatusId == 1&& d.statics==4 &&d.oddNumbers!=null){ }}
    <a class="layui-btn layui-btn-primary layui-border-black layui-btn-xs" lay-event="see">查看退回物流</a>
    {{#  } }}
    {{# if(d.statics !=5){ }}
    <a  class="layui-btn layui-btn-primary layui-border-black layui-btn-xs" lay-event="complete" >完成</a>
    {{#  } }}
    {{# if(d.statics ==5){ }}
    <a  class="layui-btn layui-btn-primary layui-border-red layui-btn-xs" lay-event="del" >删除</a>
    {{#  } }}
</script>
<script>
    var notify;
    layui.use(['notify'],function(){
        notify=layui.notify;
    })
    layui.use(['table','form'], function () {
        var table = layui.table;
        var layer = layui.layer;
        var form=layui.form;
        var tableIns =table.render({
            elem: '#orderReturnTable'
            , method: 'post'
            , title: '订单退货表'
            , url: '/reterngood/page' //数据接口
            , page: {theme: '#585a5c'}
            ,contentType:'application/json'
            , limit: 10
            ,even:'true'
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.records//解析数据列表
                };
            }
            , cols: [
                [ //表头
                    {type: 'numbers', title: '序号'}
                    ,{field: 'number',width:180,title: '售后单编号'}
                    ,{field: 'staticsString',width:150,style:' color: #1E9FFF',title: '售后单状态'}
                    ,{field: 'orderUuid',width:180,title: '订单编号'}
                    ,{field: 'amount',width: 100,title: '售后金额'}
                    ,{field: 'cargoStatus',width: 150,style:' color: #1E9FFF',title: '订单状态'}
                    ,{field: 'refund',width: 100,title: '售后方式'}
                    ,{field: 'reason',width: 150,title: '售后理由'}
                    ,{field: 'remarks',width: 150,title: '备注'}
                    ,{field: 'ceaterTime',width: 180,title: '申请时间'}
                    ,{fixed: 'right', toolbar: '#barlist',width: 280,title: '操作'}
                ]
            ]
        });

        layui.$('#orderButton').on('click', function() {
            var data = form.val('exampleOrder');
            var orderDate = {
                "orderUuid": data.orderUuid,
                "number": data.saleUuid,
            }
            tableIns.reload({
                where:orderDate
                ,page: {
                    curr: 1
                }
            });
        })
        //监听行工具事件
        table.on('tool(orderTable)', function(obj){
            var data = obj.data;
            if(obj.event === 'agree'){
                var reternVo={
                    "id":data.id,
                    "orderId":data.orderId,
                    "statics":2,
                }
                $.ajax({
                    type : "POST",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(reternVo),
                    dataType: "json",
                    url:"/reterngood/update",
                    async : true,
                    success : function(date){
                        if (date.code==0) {
                            notify.success(date.msg)
                        }else {
                            notify.error(date.msg)
                        }
                    }
                })
            }else if (obj.event === 'reject'){
                var reternVo={
                    "id":data.id,
                    "orderId":data.orderId,
                    "statics":3,
                }
                $.ajax({
                    type : "POST",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(reternVo),
                    dataType: "json",
                    url:"/reterngood/update",
                    async : true,
                    success : function(date){
                        if (date.code==0) {
                            notify.success(date.msg)
                        }else {
                            notify.error(date.msg)
                        }
                    }
                })
            } else if(obj.event === 'see'){
                //售后完成
                layer.open({
                    type: 2,
                    title: '售后物流信息',
                    fixed: false, //不固定
                    maxmin: true, //开启最大化最小化按钮
                    anim: 4,
                    area: ['1400px', '90%'],
                    scrollbar: false, //屏蔽滚动条
                    content: 'logistics_information.html?id='+data.oddNumbers,
                });
            } else if(obj.event === 'complete'){
                var reternVo={
                    "id":data.id,
                    "orderId":data.orderId,
                    "statics":5,
                }
                $.ajax({
                    type : "POST",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(reternVo),
                    dataType: "json",
                    url:"/reterngood/complete",
                    async : true,
                    success : function(date){
                        if (date.code==0) {
                            notify.success(date.msg)
                            window.location.reload();
                        }else {
                            notify.error(date.msg)
                        }
                    }
                })

            }else if (obj.event === 'del') {
                //删除
              $.get("/reterngood/del",{"id":data.id},function (date) {
                  if (date.code==0) {
                      notify.success(date.msg)
                      location.reload();
                  }else {
                      notify.error(date.msg)
                  }
              })
            }
        });
    })
</script>
</html>